beam-sql.sh, a standalone launcher for Beam SQL Shell - #36305
Conversation
Summary of ChangesHello @talatuyarer, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a very useful beam-sql.sh script that significantly simplifies launching the Beam SQL shell. The script is well-designed, with features like dynamic dependency management, caching, and automatic Maven wrapper setup. The accompanying documentation updates are also clear and helpful.
My review focuses on a few areas to improve the long-term maintainability of the script and the documentation. Specifically, I've suggested centralizing hardcoded versions in the script and refactoring the dynamic POM generation for better readability. For the documentation, I've pointed out a few places where hardcoded version numbers could be replaced with more generic text to prevent the docs from becoming stale.
Overall, this is an excellent addition that will greatly improve the user experience for Beam SQL.
| # Define URLs for a stable version of the wrapper files | ||
| local mvnw_script_url="https://raw.githubusercontent.com/apache/maven-wrapper/maven-wrapper-3.2.0/src/main/wrapper/mvnw" | ||
| local wrapper_jar_url="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" | ||
|
|
||
| # We will create the properties file ourselves to specify a modern Maven version | ||
| echo "distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip" > "${wrapper_dir}/maven-wrapper.properties" |
There was a problem hiding this comment.
This block hardcodes URLs and versions for the Maven wrapper and Maven itself. For better maintainability, it's recommended to define these as constants at the top of the script in the Configuration section (lines 24-29). This would also apply to the maven-shade-plugin version on line 206. Centralizing these values makes them easier to find and update.
|
Assigning reviewers: R: @kennknowles for label website. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
kennknowles
left a comment
There was a problem hiding this comment.
This is great. I added comments for the future. I think removing the "build from source" docs right away is a good idea. We can move them to the README.md in the github repo or something, if they are needed for devs. They were never a good instruction for users.
| ./beam-sql.sh --list-versions | ||
| ``` | ||
|
|
||
| ### Option 2: Building from Source |
There was a problem hiding this comment.
Let's remove this option. Only Beam devs need to know how to build it from souce.
| DEFAULT_BEAM_VERSION="2.67.0" | ||
| MAIN_CLASS="org.apache.beam.sdk.extensions.sql.jdbc.BeamSqlLine" | ||
| # Directory to store cached executable JAR files | ||
| CACHE_DIR="${HOME}/.beamshell/cache" |
There was a problem hiding this comment.
Should we just make this .beam so that it can be for anything Beam ends up doing? Or it could be .beam-sql so that it is clearly for this SQL application. I prefer .beam
There was a problem hiding this comment.
Done. Make sense
| echo "" | ||
| echo "Options:" | ||
| echo " --version Specify the Apache Beam version (default: ${DEFAULT_BEAM_VERSION})." | ||
| echo " --runner Specify the Beam runner to use (default: direct). Supported: direct, dataflow." |
There was a problem hiding this comment.
I can already tell that this shell script will eventually graduate to something written in a language that can have a real argument parser :-)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
|
||
| ```bash | ||
| # Use a specific Beam version | ||
| ./beam-sql.sh --version 2.66.0 |
There was a problem hiding this comment.
We should also set this to the latest version during release time. We already do this for documentation.
There was a problem hiding this comment.
I dont know how can I do that. Can you help me ? @chamikaramj
There was a problem hiding this comment.
From Python you can try this:
For documentation we use this:
beam/website/www/site/config.toml
Line 107 in a3fd151
Both updated during Beam releases.
|
Thanks. LGTM. |
ahmedabu98
left a comment
There was a problem hiding this comment.
Looks great overall, just left some comments.
Also, does this support passing in pipeline options (I'm thinking to set up the Dataflow runner)
| echo " Supported runners:" | ||
| echo " direct - DirectRunner (runs locally, good for development)" | ||
| echo " dataflow - DataflowRunner (runs on Google Cloud Dataflow)" | ||
| echo " --io Specify an IO connector to include. Can be used multiple times." |
There was a problem hiding this comment.
nit: consider making this a comma-separated list for easy use
| "prism") | ||
| echo " prism - PrismRunner" | ||
| echo " Local runner for testing portable pipelines." |
| EOL | ||
| # Add IO and Runner dependencies | ||
| for io in "${IO_CONNECTORS[@]}"; do | ||
| echo " <dependency><groupId>org.apache.beam</groupId><artifactId>beam-sdks-java-io-${io}</artifactId><version>\${beam.version}</version></dependency>" >> "${POM_FILE}" |
There was a problem hiding this comment.
for Iceberg, we'll also need to add beam-sdks-java-extensions-sql-iceberg
There was a problem hiding this comment.
These things are resolved by maven I am just created a project which uses necessary dependencies.

Currently, using the Beam SQL shell requires cloning the entire Beam repository and running a complex Gradle command with specific project properties just to bundle I/O connectors (e.g.,
./gradlew ... -Pbeam.sql.shell.bundled=... installDist). This process is slow on the first run, non-intuitive, and makes it difficult to quickly experiment with different connectors.This PR introduces
beam-sql.sh, a new standalone Bash script that completely automates this process. It provides a simple, powerful, and user-friendly command-line experience for launching the SQL Shell with any required I/O connectors and runners.Key Features
The ``beam-sql.sh` script is a self-contained utility with the following features:
Dynamic Dependencies: Users can specify the Beam version, I/O connectors (
--io), and runners (--runner) directly via command-line flags.Robust JAR Building: The script dynamically generates a
pom.xmland builds a self-contained "uber JAR" using themaven-shade-plugin. It correctly uses theServicesResourceTransformerto mergeMETA-INF/servicesfiles, ensuring all specified connectors are discoverable by the JavaServiceLoader.Intelligent Caching: Successfully built JARs are cached locally in
~/.beamshell/cache. Subsequent launches with the same configuration are instantaneous, as the script finds and uses the cached JAR, skipping the build step entirely.No Maven Required: The script makes no assumption about a user's environment. It will use the system-installed
mvnif present for speed, but will automatically download and use the Maven Wrapper (mvnw) ifmvnis not found, making it highly portable.Standalone & Easy to Use: It is a single Bash script with minimal, common dependencies (
java,curl), making it easy to distribute and use.How to Use
The script provides a simple and flexible command-line interface.
1. Basic launch with Iceberg support: